Hello all,
I am having a problem when trying to replace the current Object Text with the info in the baseline. The code below works great if I don't care about the markups. However, if I do want to bring all markups over, adding "richText" in front of the string doesn't work.
Any help would be appriciated!
Shirley
=====================
string emptyList[] = {}
Module m = current Module
DB db = null
DBE dbeBaselineList = null
DBE dbeShowRedlineTgl = null
Skip skpBaselines = createString()
void initList()
{
Baseline b
string sBaselineName = ""
for b in m do
{
sBaselineName = major(b) "." minor(b) " " suffix(b)
put(skpBaselines, sBaselineName, b)
insert(dbeBaselineList, noElems(dbeBaselineList), sBaselineName)
}
}
void doApply(DB xx)
{
string sBaselineName = get(dbeBaselineList)
bool bShowMarkup = get(dbeShowRedlineTgl)
Baseline b
if(! find(skpBaselines, sBaselineName, b)) halt
int iMajor = major(b)
int iMinor = minor(b)
string sSuffix = suffix(b)
if(null sSuffix) sSuffix = "\"\""
int iNumCols = 0
Column c
for c in m do iNumCols++
c = column(iNumCols)
Buffer bufCode = create()
bufCode += " bool bShowMarkup = " bShowMarkup "\n"
bufCode += " int iMajor = " iMajor "\n"
bufCode += " int iMinor = " iMinor "\n"
bufCode += " string sSuffix = \"" sSuffix"\" \n"
bufCode += " string sNewTxt = null \n"
bufCode += " string sOldTxt = null \n"
bufCode += " string sNewHead = null \n"
bufCode += " string sOldHead = null \n"
bufCode += " Module modBase \n"
bufCode += " Object oldObj \n"
bufCode += " Baseline b = baseline(iMajor, iMinor, sSuffix) \n"
bufCode += " int iAbsNo = obj.\"Absolute Number\" \n"
bufCode += " if(!null b) { \n"
bufCode += " modBase = load(b,false) \n"
bufCode += " oldObj = object(iAbsNo, modBase) \n"
bufCode += " if(null oldObj) display \"NEW OBJECT\" \n"
bufCode += " else { \n"
bufCode += " sNewTxt = obj.\"Object Text\" \n"
bufCode += " sOldTxt = richText(oldObj.\"Object Text\") \n"
bufCode += " sNewHead = obj.\"Object Heading\" \n"
bufCode += " sOldHead = oldObj.\"Object Heading\" \n"
bufCode += " if(bShowMarkup) { \n"
bufCode += " Buffer bufOld = create() \n"
bufCode += " Buffer bufNew = create() \n"
bufCode += " Buffer bufRes = create() \n"
bufCode += " if(null sNewTxt && null sOldTxt) { \n"
bufCode += " bufOld = sOldHead \n"
bufCode += " bufNew = sNewHead \n"
bufCode += " obj.\"Object Heading\" = sOldHead \n"
bufCode += " } else { \n"
bufCode += " bufOld = sOldTxt \n"
bufCode += " bufNew = sNewTxt \n"
bufCode += " obj.\"Object Text\" = sOldTxt \n"
bufCode += " } \n"
bufCode += " diff(bufRes, bufOld, bufNew) \n"
bufCode += " displayRichWithColor(stringOf(bufRes)) \n"
bufCode += " } else { \n"
bufCode += " if(sNewTxt != sOldTxt || sNewHead != sOldHead) display \"CHANGED\" \n"
bufCode += " else display \"\" } } } \n"
dxl(c, stringOf(bufCode))
width(c, 250)
title(c, "Changes from " sBaselineName )
delete(bufCode)
if(!null skpBaselines) delete skpBaselines
hide xx
refresh(m)
}
db = create "Insert baseline compare column"
dbeBaselineList = list(db, "Baseline to compare with: ", 30, 5, emptyList)
dbeShowRedlineTgl = toggle(db, "Show redline markup", false)
apply(db, "Insert column", doApply)
realize(db)
initList()
setExtraHeightShare(dbeBaselineList, 1.0)
show(db)
DOORSUser - Wed Dec 11 10:47:56 EST 2013 |
Re: Replace with Baseline if current is changed llandale - Thu Dec 12 16:23:05 EST 2013
The "diff" function definately does not like richText input; so you should routinely retrieve "Raw Text" for that purpose. If you want to deal with the text as rich, then retrieve it into a different attribute.
-
bufOld_Raw = oldObj."Object Text"
-
<use bufOld_Raw in the "diff" command>
-
-
bufOld_Rich = richTextWithOle(oldObj."Object Text")
-
oCurrent."Object Text" = richText(bufOld_Rich)
On a more serious note; I think it a disaster for your layout to be attempting to modify Object Text of the current Object. Surely you should update the object mindfully in your main code; and have some simple Layout that displays differences betweena specific baseline and the current values.
For whatever its worth, I'd have the difference displayed on some richText DBE on the dialog; showing the differences of the current object with the selected baseline.
|